package necer.ncalendardemo.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.tencent.smtt.sdk.WebView;

import necer.ncalendardemo.R;
import necer.ncalendardemo.errview.LoadingController;
import necer.ncalendardemo.errview.LoadingInterface;

public class NetActivity extends AppCompatActivity{

    private TextView tv;
    private LoadingController loadingController;
    private WebView txwebview;

    /**
     * @param savedInstanceState
     */
    @Override
    protected void onCreate(Bundle savedInstanceState){

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_net);
        tv = (TextView) findViewById(R.id.tv);
        txwebview = (WebView) findViewById(R.id.txwebview);
        loadingController = new LoadingController.Builder(this, tv).
                 setOnNetworkErrorRetryClickListener(new LoadingInterface.OnClickListener() {
            @Override
            public void onClick() {
                loadingController.showError();
            }
        }).setOnErrorRetryClickListener("点我重试", new LoadingInterface.OnClickListener() {
            @Override
            public void onClick() {
                loadingController.showLoading();
            }
        }).build();

    }

    public void ddd(View view){

/*
        OkHttpUtils.get().url("https://blog.csdn.net/matangtang/article/details/72538597").build().execute(new StringCallback(){
            @Override
            public void onError(Request request, Exception e){
                Log.e("dwd",e.getMessage());
            //    Toast.makeText(NetActivity.this, "请求错误", Toast.LENGTH_SHORT).show();

                if(NetworkUtil.isNetworkAvailable(NetActivity.this)==true){

                    loadingController.showError();
                }else {
                    loadingController.showNetworkError();
                }



            }

            @Override
            public void onResponse(String response){
                Log.e("NetActivity", response);
                Toast.makeText(NetActivity.this, "请求成功", Toast.LENGTH_SHORT).show();
            }
        });
*/
        //   txwebview.loadUrl("https://blog.csdn.net/matangtang/article/details/72538597");

     txwebview.loadUrl("https://home.firefoxchina.cn/?from=extra_start");
    }
}
